/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package sys.donto.prontuario;

import java.util.Date;
import java.util.List;
import java.util.Objects;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Temporal;
import sys.donto.paciente.Paciente;
import sys.donto.servico.Servico;

/**
 *
 * @author JOABB
 */
@Entity
public class Prontuario {
    @GeneratedValue
    @Id
    private int id;
    
    @Temporal(javax.persistence.TemporalType.DATE)
    private Date dataAtualizacao;
    
    @ManyToOne
    private Paciente paciente;
      
    @OneToMany(mappedBy = "prontuario", fetch = FetchType.EAGER)
    private List<Servico> servi;

    /**
     * @return the id
     */
    public int getId() {
        return id;
    }

    /**
     * @param id the id to set
     */
    public void setId(int id) {
        this.id = id;
    }

    /**
     * @return the dataAtualizacao
     */
    public Date getDataAtualizacao() {
        return dataAtualizacao;
    }

    /**
     * @param dataAtualizacao the dataAtualizacao to set
     */
    public void setDataAtualizacao(Date dataAtualizacao) {
        this.dataAtualizacao = dataAtualizacao;
    }

    /**
     * @return the paciente
     */
    public Paciente getPaciente() {
        return paciente;
    }

    /**
     * @param paciente the paciente to set
     */
    public void setPaciente(Paciente paciente) {
        this.paciente = paciente;
    }

    /**
     * @return the servi
     */
    public List<Servico> getServi() {
        return servi;
    }

    /**
     * @param servi the servi to set
     */
    public void setServi(List<Servico> servi) {
        this.servi = servi;
    }

    @Override
    public int hashCode() {
        int hash = 5;
        hash = 61 * hash + this.id;
        hash = 61 * hash + Objects.hashCode(this.dataAtualizacao);
        hash = 61 * hash + Objects.hashCode(this.paciente);
        hash = 61 * hash + Objects.hashCode(this.servi);
        return hash;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final Prontuario other = (Prontuario) obj;
        if (this.id != other.id) {
            return false;
        }
        if (!Objects.equals(this.dataAtualizacao, other.dataAtualizacao)) {
            return false;
        }
        if (!Objects.equals(this.paciente, other.paciente)) {
            return false;
        }
        if (!Objects.equals(this.servi, other.servi)) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "Prontuario{" + "id=" + id + ", dataAtualizacao=" + dataAtualizacao + ", paciente=" + paciente + ", servi=" + servi + '}';
    }

    
}
